package com.cqw.commontest.io;

import java.io.*;

/**
 * @Author: caoqingwen
 * @CreateTime: 2021-04-25 17:10
 * @Description: 字符流
 */
public class FileInputStreamTest {

    /**
     * FileInputStream 字节输入流
     * 1、用于从文件中读取信息(可以是中文、图片、视频、音乐)
     */


    public static void main(String[] args) {
        File file = new File("D:\\fileTest\\1.mp4");
        try {
            FileInputStream fileInputStream = new FileInputStream(file);
            FileOutputStream fileOutputStream = new FileOutputStream(new File("D:\\fileTest\\2.mp4"));
            //借助一个 byte 数组来接收读取到值
            byte[] bytes = new byte[1024 * 1024];
            int len;
            while ((len = fileInputStream.read(bytes)) != -1) {
                fileOutputStream.write(bytes, 0, len);
            }
            fileInputStream.close();
            fileOutputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }


    }


}
